<?php

namespace app\admin\controller\vv;

use app\common\controller\Backend;
use Carbon\Carbon;
use vv\model\Shop;

class Dashboard extends Backend
{
    public function index()
    {
        $now = Carbon::now();

        return $this->fetch('', [
            'd1' => Shop::where('shoptype', 2)->count(),
            'd2' => \vv\model\Category::count(),
            'd3' => \vv\model\Goods::count(),
            'd4' => \vv\model\Order::where('state', 'in', [2, 3, 4, 6])->where('createtime', '>=', $now->startOfDay()->timestamp)->count(),
            'd5' => \vv\model\Order::where('state', 'in', [2, 3, 4, 6])->where('createtime', '>=', $now->startOfMonth()->timestamp)->count(),
            'd6' => \vv\model\Order::where('state', 2)->count(),
        ]);
    }
}